\setcounter{ipycommand}{0}

\begin{frame}
\frametitle{Simple ITK}
\overlayicon{Logo/itk}
\begin{itemize}
\item Introduction to ITK
\item Introduction to SimpleITK
\item Getting SimpleITK
\item Basic Operations
\item Advanced Operations
\item Building Bridges with Other Libraries
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{What is ITK ?}
\overlayicon{Logo/itk}
\begin{itemize}
\item C++ Library
\item Open Source (Apache 2.0 License)
\item Generic Programming / C++ Templates
\item Image Processing
\item Image Segmentation
\item Image Registration
\pause
\item ITK's main foci are segmentation and registration, especially in
the context of 3D images.
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Funding}
\overlayicon{Logo/itk}
\begin{itemize}
\item Funded (mostly) by the US National Library of Medicine
\pause
\item With contributions from
\begin{itemize}
\item National Institute of Dental and Craniofacial Research
\item National Science Foundation
\item National Eye Institute
\item National Institute of Neurological Disorders and Stroke
\item National Institute of Mental Health
\item National Institute on Deafness and Other Communication Disorders
\item National Cancer Institute
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{History}
\overlayicon{Logo/itk}
\begin{itemize}
\item Started in 2000
\pause
\item Developed by Companies and Universities
\begin{itemize}
\item GE Corporate Research
\item Insightful
\item Kitware
\item UNC Chapel Hill
\item University of Pennsylvania
\item University of Utah
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{History}
\overlayicon{Logo/itk}
\begin{itemize}
\item Recent contributions by a larger community
\begin{itemize}
\item Harvard - Brigham and Women's Hospital
\item University of Iowa
\item Georgetown University
\item INRA - France
\item German Cancer Research Center
\item \ldots and many others \ldots
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Project Profile}
\overlayicon{Logo/itk}
\begin{itemize}
\item Total lines of code: 1,886,674
\item Active developers: 56 (past 12 months)
\item Total developers: 146 (full history of the project)
\item Top 2\% largest open source teams in the world
\item Estimated cost of development: \$34.5 M\footnote{Ohloh: \url{http://www.ohloh.net/p/itk}}
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Funding}
\overlayicon{Logo/itk}
\begin{itemize}
\item First 10 years of development = \$15M
\pause
\item Refactoring of ITKv4 in 2011 = \$5M
\pause
\item Yearly maintenance supported by NLM
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Simple ITK}
\overlayicon{Logo/itk}
\reference{
More info: \url{http://simpleitk.org}
}
SimpleITK provides a template-free layer on top of ITK that is
automatically wrapped for Python.
\end{frame}

\begin{frame}[fragile]
\frametitle{Installing Simple ITK}
\overlayicon{Logo/itk}
\begin{itemize}
\item Two main options are building from source with Python wrappings
\item Or easy\_install (easy\_install is much easier).
\end{itemize}
\begin{lstlisting}
bash ~/ easy_install SimpleITK  # It's that easy (you may have to be root).
\end{lstlisting}
\begin{itemize}
\item Let's walk through an example of basic Simple ITK usage
from \texttt{Examples/sitk\_intro.py}.
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Creating Images with Simple ITK}
\overlayicon{Logo/itk}
\begin{itemize}
\item It's very easy to create images using SimpleITK.
\item The images will be two-dimensional or three-dimensional based on
  the constructor
\end{itemize}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{4}{9}{Examples/sitk_intro.py}
\end{frame}

\begin{frame}
\frametitle{Creating Images with Simple ITK}
\overlayicon{Logo/itk}
\begin{itemize}
  \item sitk is the module
  \item Image is the constructor for the Image class
  \item Height, width, depth (omit depth for 2D images)
  \item Datatype (more on this later)
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{What just happened?}
\overlayicon{Logo/itk}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{11}{14}{Examples/sitk_intro.py}
\begin{itemize}
  \item Get the voxel value at [0,0,0]?
  \item Hmm, I don't like it, so set to 1
  \item What is the value at [0,0,0] now?
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{What just happened?}
\overlayicon{Logo/itk}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{16}{19}{Examples/sitk_intro.py}
Without warning, we sprinkled syntactic sugar on you!
\begin{itemize}
  \item \lstpy{image[0,0,0]} is shorthand for \lstpy{image.GetPixel(0,0,0)}
  \item \lstpy{image[0,0,0] = 10} is shorthand for
    \lstpy{image.SetPixel(0,0,0,10)}
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{SimpleITK Pixel Types}
\overlayicon{Logo/itk}
\begin{itemize}
\item Simple ITK supports a wide array of pixel types
\item To get a human readable assessment of the pixel type:
\end{itemize}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{21}{21}{Examples/sitk_intro.py}
\end{frame}

\begin{frame}[fragile]
\frametitle{SimpleITK Image Summary}
\overlayicon{Logo/itk}
\begin{itemize}
  \item Images are created using \lstpy{SimpleITK.Image ( w, h, d, Type )}
  \item Images can be 2- or 3-dimensional
  \item Images can describe themselves
  \item Images have simple pixel accessors
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Filtering with SimpleITK}
\overlayicon{Logo/itk}
\begin{itemize}
\item Basic operations are very simple
\item Let's look at an image with a Gaussian subtracted from it:
\end{itemize}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{22}{22}{Examples/sitk_intro.py}
\begin{itemize}
  \item The output of SmoothingRecursiveGaussian is of type float
  \item The input image is signed short
  \item Most SimpleITK filters with 2 inputs require the same type
  \item We need to cast in order to difference the input image with
  the smoothed image
\end{itemize}

\end{frame}

\begin{frame}[fragile]
\frametitle{Introducing Cast}
\overlayicon{Logo/itk}
\begin{itemize}
\item The Cast Filter works as you would expect.
\end{itemize}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{25}{29}{Examples/sitk_intro.py}
\end{frame}


\begin{frame}[fragile]
\frametitle{Sizes and Indices}
\overlayicon{Logo/itk}
\begin{itemize}
\item Extracting a region of interest from a SimpleITK image is easy
      with \lstpy{sitk.Extract}.
\end{itemize}
\lstset{title=Examples/sitk\_intro.py}
\lstlistingwithnumber{31}{34}{Examples/sitk_intro.py}
\end{frame}

\begin{frame}[fragile]
\frametitle{More Advanced Filtering}
\overlayicon{Logo/itk}
\begin{itemize}
\item Now that we can do basic filtering, let's look at more advanced
      filters
\item How about Otsu Thresholding?
\end{itemize}
\lstset{title=Examples/sitk\_example.py}
\lstlistingwithnumber{11}{18}{Examples/sitk_example.py}
\begin{itemize}
\item Notice that filters can also be instantiated as objects
\end{itemize}
\end{frame}


\begin{frame}[fragile]
\frametitle{More Advanced Filtering}
\overlayicon{Logo/itk}
\begin{itemize}
\item We can run nearly every filter from ITK in this manner and
quickly view results (as shown below).
\item Bonus: \texttt{sitk.Show} allows us to view 3D Images with ImageJ
\end{itemize}
\begin{center}
\includegraphics[width=0.45\linewidth]{ScreenShot/sitk_input}
\includegraphics[width=0.45\linewidth]{ScreenShot/sitk_otsu}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{Integration with NumPy}
\overlayicon{Logo/itk}
\begin{itemize}
\item Let's look at integrating SimpleITK with NumPy.
\end{itemize}
\lstset{title=Examples/sitk\_numpy.py}
\lstlistingwithnumber{11}{31}{Examples/sitk_numpy.py}
\end{frame}

\subsection{Exercise 4}

\begin{frame}[fragile]
\frametitle{Exercise 4}
\framesubtitle{SimpleITK}
\overlayicon{Logo/itk}
\begin{itemize}
\item Open the file \verb|Exercises/ex4.py|.
\item Let's take the previous examples and build on them.
\begin{enumerate}
\item Use \lstpy{sitk.RecursiveGaussian} to smooth the image, \\
      then plot the histogram with Matplotlib.
\item Use \lstpy{sitk.Threshold} to segment bone from the input image.
\end{enumerate}
\item Hint: Bone has intensity greater than 210 in this image.
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Exercise 4: Answer}
\framesubtitle{SimpleITK}
\overlayicon{Logo/itk}
\begin{itemize}
\item Great Job! your code should look something like this
\end{itemize}
\lstset{title=Exercises/Answers/ex4-answer.py}
\lstlistingwithnumber{11}{33}{Exercises/Answers/ex4-answer.py}
\end{frame}

\begin{frame}[fragile]
\frametitle{More Advanced Filtering}
\overlayicon{Logo/itk}
\begin{itemize}
\item Your bone segmentation should look something like this.
\end{itemize}
\begin{center}
\includegraphics[width=0.4\linewidth]{ScreenShot/sitk_exercise_ans}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{Credits}
Material taken from the following tutorials:
\begin{itemize}
\item The SimpleITK tutorial from MICCAI 2011
      (\url{https://github.com/SimpleITK/SimpleITK-MICCAI-2011-Tutorial}).
\item The ITKv4 next generation tutorial
      (\url{https://github.com/InsightSoftwareConsortium/ITKv4-TheNextGeneration-Tutorial}).
\end{itemize}
\end{frame}
